<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>平台预收款报表</title>
    <jsp:include page="../../head.jsp"/>
    <script type="text/javascript" src="<s:url value="/js/ajaxutil.js"/>"></script>
</head>
<script type="text/javascript">
    var formSetting = {
        title: "平台预收款报表",
        module: 'query',
        numCount: '2',
        columns: [{
            index: "REGDATE",
            name: "regDate",
            type: "date",
            label: "统计时间起",
            op: "ge"
        }, {
            index: "REGDATE",
            name: "regDate",
            label: "统计时间止",
            type: "date",
            op: "le"
        }],
        buttons: {
            custom: [{
                id: "buildNewReport",
                value: "生成新一期报表",
                click: function () {
                    var startDate = $("input#form_in_control_1.hasDatepicker").val();
                    var endDate = $("input#form_in_control_2.hasDatepicker").val();
                    if ($("#dataGrid tr.jqgrow").length > 0) {
                        jw.alert("当前时间段已存在报表记录，请选择正确的统计时间段。");
                    }
                    else if ("" == startDate || "" == endDate) {
                        jw.alert("请填写完整的统计起始结束时间。");
                    }
                    else {
                        jw.confirm("确定要生成新一期报表？", function () {
                            ajaxLoader.ajaxPost("report-buildAllReport", {
                                startDate: startDate,
                                endDate: endDate
                            }, function (data) {
                                try {
                                    jw.alert(JSON.parse(data.msg).msg);
                                } catch (e) {
                                }
                                setTimeout(function () {
                                    $("#queryButton").click();
                                }, 1000);
                            });
                        });
                    }
                }
            }]
        },
        grid: {
            id: "dataGrid",
            title: "查询结果",
            url: "report-findManagerList",
            colModel: [{
                index: "id",
                name: "id",
                label: "id",
                hidden: true
            }, {
                index: "COM",
                name: "owner.name",
                label: "客户公司"
            }, {
                index: "preRegDate",
                name: "preRegDate",
                formatter: 'date',
                formatoptions: {
                    srcformat: 'Y-m-d H:i:s',
                    newformat: 'Y-m-d H:i:s'
                },
                label: "统计起始时间"
            }, {
                index: "regDate",
                name: "regDate",
                formatter: 'date',
                formatoptions: {
                    srcformat: 'Y-m-d H:i:s',
                    newformat: 'Y-m-d H:i:s'
                },
                label: "统计截止时间"
            }, {
                index: "preBalance",
                name: "preBalance",
                label: "上期预收款结余（元）"
            }, {
                index: "income",
                name: "income",
                label: "本期预收款金额(元)"
            }, {
                index: "cost",
                name: "cost",
                label: "本期实际业务发生额(元)"
            }, {
                index: "balance",
                name: "balance",
                label: "本期预收款结余(元)"
            }],
            sortname: "regDate",
            sortorder: "desc",
            jsonReader: {
                root: "datas"
            },
            loadComplete: function (data) {
            }
        }
    };
    $(document).ready(function () {
        $("#dataTable").mrdForm(formSetting);
    });
</script>
<body>
<div id="dataTable"></div>
</body>
</html>
